package edu.hit.irlab.coref.features.pair;

import java.util.List;

import edu.hit.irlab.coref.mentionfinder.MentionFinder;
import edu.hit.irlab.coref.util.GenderCalc;
import edu.hit.irlab.coref.PairFeatureExtractor;
import edu.hit.irlab.coref.PairInstance;

import nlpeap.ml.TriValue;
import nlpeap.ml.FeatureDescription;
import nlpeap.ml.FeatureType;

import nlpeap.feature.basictypes.GenderType;

/**
 * Feature used to determine whether gender of the pair instance matches.
 * The values are Either TRUE/FALSE/UNKNOWN
 * 
 * @author chuter
 */
public class FE_Gender implements PairFeatureExtractor{
    private final GenderCalc _gender_ins = GenderCalc.getInstance();
    public static final FeatureDescription<TriValue> FD_IS_GENDER=
            new FeatureDescription<TriValue>(FeatureType.FT_NOMINAL_ENUM, TriValue.class, "Gender");
    
    
 
    public void describeFeatures(List<FeatureDescription> fds) {
        fds.add(FD_IS_GENDER);
    }

    public void extractFeatures(PairInstance inst) {    	
    	GenderType gender_type_ant = _gender_ins.calcGendertype(inst.getAntecedent());
    	GenderType gender_type_ana = _gender_ins.calcGendertype(inst.getAnaphor());
        if (
        			gender_type_ant.equals(GenderType.UNKNOWN)
        		||
        			gender_type_ana.equals(GenderType.UNKNOWN)
        	)
        	inst.setFeature(FD_IS_GENDER, TriValue.UNKNOW);
        else if (gender_type_ant.equals(gender_type_ana))
        	inst.setFeature(FD_IS_GENDER, TriValue.TRUE);
        else
        	inst.setFeature(FD_IS_GENDER, TriValue.FALSE);
    	
    }

}

